<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="button" value="download" onclick="download()">
    <script>
        var a = document.createElement("a");
        a.href = "8.js";
        a.download = "8.js"
        for (const k in a) {
            if (k.startsWith('on')) {
                // console.log(k);
                a[k]=function(e){
                    console.log(e);
                }
            }

        }
        function download() {
            a.click();
        }
    </script>
</body>

</html>